﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;


namespace CTEA_INDIA
{
    public partial class Team : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["CTEA"].ConnectionString;
            populateProductionTeam();
            if (!IsPostBack)
            {
                if (Session["UserID"] == null)
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            int Productoin_TeamId=Convert.ToInt32(Session["TeamId"]);
           ////  Team A
            string Director_Name = txtDirectorName.Text;
            string _Writer = txtWriter.Text;
            string Casting_Director = txtCastingDirector.Text;
            string Marketing_Head = txtMarketingHead.Text;
            string Creative_Director = txtCreativeDirector.Text;
            string Music_Director = txtMusicDirector.Text;
            string Dance_Director = txtDanceDirector.Text;
            string Art_Director = txtArtDirector.Text;
            string Fashion_Designer = txtFashionDirector.Text;

            ///// Team B
            string Executive_Producer = txtExecutiveProducer.Text;
            string _Dop = txtDop.Text;
            string Production_Manager = txtProductionManager.Text;
            string Assistant_Director = txtAssistantDirector.Text;
            string Head_Media_Manager = txtHeadMediaManager.Text;
            string supplier = txtSupplier.Text;


            BAL.Customers.Team(Director_Name , _Writer , Casting_Director ,Marketing_Head , Creative_Director , Music_Director ,
                Dance_Director , Art_Director , Fashion_Designer , Executive_Producer , _Dop , Production_Manager ,
                Assistant_Director , Head_Media_Manager,Productoin_TeamId,supplier);

            spnMsgs.Visible = true;
            spnText.InnerHtml = "Your details have been submitted.";

            populateProductionTeam();
            txtDirectorName.Text = "" ;
            txtWriter.Text = "";
            txtCastingDirector.Text = "";
            txtMarketingHead.Text = "";
            txtCreativeDirector.Text = "";
            txtMusicDirector.Text = "";
            txtDanceDirector.Text = "";
            txtArtDirector.Text = "";
            txtFashionDirector.Text = "";
            txtExecutiveProducer.Text = "";
            txtDop.Text = "";
            txtProductionManager.Text = "";
            txtAssistantDirector.Text = "";
            txtHeadMediaManager.Text = "";
            txtSupplier.Text = "" ;
            txtDop.Text = "" ;
            txtProductionManager.Text ="" ;
            txtAssistantDirector.Text = "" ;
            txtHeadMediaManager.Text = "";
                   

        }


        public void populateProductionTeam()
        {

            DataSet ds = BAL.Customers.ViewAllProductionTeam();
            gdProductionTeam.DataSource = ds;
            gdProductionTeam.DataBind();

        }


        protected void gdProductionTeam_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gdProductionTeam.PageIndex = e.NewPageIndex;
            populateProductionTeam();
        }


        protected void gdProductionTeam_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lEdit = (LinkButton)e.Row.FindControl("lnkEdit");
                Button update = (Button)e.Row.FindControl("btnUpdate");
                LinkButton lDelete = (LinkButton)e.Row.FindControl("lnkDelete");
                lDelete.CommandArgument = e.Row.RowIndex.ToString();
            }

        }

        protected void lnkView_Click(object sender, EventArgs e)
        {
            LinkButton lnkVw = sender as LinkButton;
            GridViewRow row = (GridViewRow)lnkVw.Parent.Parent;


            int Cid = Convert.ToInt32(gdProductionTeam.DataKeys[row.RowIndex]["ProductionTeamId"]);
            string[] Details = BAL.Customers.GetProductionTeamById(Cid);
            lblPCN.Text = Details[1];
            lblRegWith.Text = Details[2];
            lblRegNo.Text = Details[3];
            lblIncDate.Text = DateTime.Parse(Details[4]).ToShortDateString().ToString();
            lblRegAddr.Text = Details[5];
            lblCorpAddr.Text = Details[6];
            lblContact.Text = Details[7];
            lblEmail.Text = Details[8];
            lblProducerName.Text = Details[9];
            lblAssoProducer.Text = Details[10];
            lblInvCompany.Text = Details[11];
            lblInvName.Text = Details[12];
            lblPBN.Text = Details[13];
            lblBudget.Text = Details[14].ToString() + "lakh to" + Details[15].ToString() + "cr";
            lblSupplier.Text = Details[15];












            lnkView_ModalPopupExtender.Show();


        }


    }
}